<template>
  <div>
    <button @click="getUser">获取用户信息</button>
    <button @click="getPower">获取力量来源</button>
</div>
</template>

<script>
import axios from 'axios'

export default {
  name: "myTest",
  methods: {
     getUser(){
        /**
         * (1) http://localhost:8080这里的是代理服务器，后面getUser告诉服务器想要获得什么数据
         * (2) 如果要访问的资源本机(public里面的)8080有，就不会转发给8091去了
         * */ 
        axios.get('http://localhost:8080/server1/getUser').then(
          response => {
            console.log('请求成功了!',response.data);
          },
          err =>{
            console.log('请求失败了!',err.mesage);
          }
        )
     },
     getPower(){
        axios.get('http://localhost:8080/server2/getPower').then(
          response => {
            console.log('请求成功了!',response.data);
          },
          err =>{
            console.log('请求失败了!',err.mesage);
          }
        )
     }
  },
};
</script>